class FishItem extends eui.Component implements  eui.UIComponent {
	private fish_icon:eui.Image;
	private lb_money:eui.Label;
	private data;

	public constructor(data?:any) {
		super();
		this.data = data;
	}

	public update(data)
	{
		if(data)
		{
			this.fish_icon.source = data["tujianicon"];
			this.lb_money.text = '+ $' + data["price"];
			if(data["isNeedRotation"] == 0)
			{
				this.fish_icon.x = 80;
			}
			else
			{
				this.fish_icon.x = 30;
			}
		}
	}

	protected childrenCreated():void
	{
		super.childrenCreated();
		this.update(this.data);
	}

	public Move()
	{
		EffectUtil.instance().StopEffect(this);
		WeChatgGameManager.instance().vibrateShort();
		egret.Tween.get(this).to({
			y:this.y - 200,
			alpha:0
		},400).call(()=>{
			if(this.parent)
				this.parent.removeChild(this);
			this.alpha = 1;
			FishItemPool.pushOneFishItem(this);
		})
	}

	public destory()
	{
		EffectUtil.instance().StopEffect(this);
		this.fish_icon = null;
		this.data = null;
		this.lb_money = null;
	}
}

//对象池
class FishItemPool{
	private static itemList:FishItem[] = [];
	private static MaxItemNum:number = 10;

	//获取一个鱼类Item
	public static getOneFishItem(data):FishItem
	{
		let Item:FishItem;
		if(this.itemList.length > 0)
		{
			Item = this.itemList.shift();
			Item.update(data);
		}
		else
		{
			Item = new FishItem(data);
		}

		return Item;
	}

	//加入一个鱼类item
	public static pushOneFishItem(Item:FishItem)
	{
		if(this.itemList.length < this.MaxItemNum)
		{
			this.itemList.push(Item);
		}
	}

	public static clear()
	{
		for(let v of this.itemList)
		{
			v.destory();
		}
		this.itemList = [];
	}
}